<dom-module id="poly-tabls">
    <template>
        <div>
        1:需求 实现大文件的子列表的某一项进行更新进度. 开发测试:点击选择 ,点击刷新进度,更新选择中的信息,进度状态<br>
        2: 需要的 开发需要的库在weber_components<br>
           iron-collapse 文件列表是否折叠<br>
           iron-data-table 展示列表的表格<br>
        </div>

        <template is="dom-repeat" items="{{bigItems}}">
            <h2 style="border-bottom: 1px solid #0b8043">
                大文件: {{item.file_name}} ---- 文件info:{{item.info_hash}}
            </h2>

            <h3 id="collapse{{index}}" on-click="opencollapse">小文件信息列表</h3>
            <!--<button class="heading" aria-expanded$="[[isExpanded(opened1)]]" aria-controls="collapse1" onclick="toggle('#collapse1')">Collapse #1</button>-->
            <!--<iron-collapse  id="collapse1" tabindex="0" opened="{{opened1}}">-->
            <iron-data-table items="[[item.subFiles]]" selection-enabled multi-selection>>
                <data-table-column name="文件ID" width="50px" flex="0">
                    <template>
                        {{item.id}}
                    </template>
                </data-table-column>
                <data-table-column name="文件名字">
                    <template>
                        {{item.filename}}
                    </template>
                </data-table-column>
                <data-table-column name="文件大小">
                    <template>
                        [[item.size]]M
                    </template>
                </data-table-column>
                <data-table-column name="文件进度">
                    <template>
                        [[item.percent]] %
                    </template>
                </data-table-column>
            </iron-data-table>

            <!--</iron-collapse>-->
            <button on-click="refreshItemData" style="float: right">点击刷新进度信息</button>
        </template>
    </template>

</dom-module>
<script>
    Polymer({
        is: 'poly-tabls',
        properties: {

            bigItems: {
                type: Array,
                value: [
                    {id: 1, info_hash: "adfdsfxxx123456",  file_name:"龙珠大战",subFiles: [
                            {id: 1, filename: "龙珠大战一集abc1", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 2, filename: "龙珠大战一集abc2", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 3, filename: "龙珠大战一集abc3", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 4, filename: "龙珠大战一集abc4", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 5, filename: "龙珠大战一集abc5", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 6, filename: "龙珠大战一集abc6", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 7, filename: "龙珠大战一集abc7", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 8, filename: "龙珠大战一集abc8", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 9, filename: "龙珠大战一集abc9", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},

                        ]
                    },
                    {id: 2, info_hash: "adfdsfxxx123456",  file_name:"西游记",subFiles: [
                            {id: 1, filename: "西游记一集abc1", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 2, filename: "西游记一集abc2", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 3, filename: "西游记一集abc3", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 4, filename: "西游记一集abc4", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 5, filename: "西游记一集abc5", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 6, filename: "西游记一集abc6", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 7, filename: "西游记一集abc7", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 8, filename: "西游记一集abc8", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},
                            {id: 9, filename: "西游记一集abc9", size: 1000, state: "", percent: 0, url: "chinatorrent.bt.com",},

                        ]
                    },

                ]
            },

        },
        // state : "":0  待下载 , inprogres:0-100  下载中 ;100  complete:下载完成
        // percent: 10% 更新下载进度状态

        refreshItemData: function () {
            var percent = 0;
            var state="inprogres"
            setInterval(function () {
                if(percent===0){
                    state="";
                }else if(percent>0&&percent<100){
                    state="inprogres";
                }else if (percent===100) {
                    state="complete";
                }else{
                    state="其他状态";
                }
                percent = percent + 2;

                console.log("下载进度:",percent+"%");

            }, 3000)
        },
        opencollapse: function (e) {
            var collapse = e.target.id;
            var newIndexId = (collapse + "").split("collapse");
            console.log("split(downloadclick)", ('#collapse' + newIndexId[1]));
            this.$$("#tabls" + newIndexId[1]).click(
                alert("点击测试")
            );
        }


    });
</script>
